package edu.ilstu.mind.ise.ccp.config;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.Reader;
import java.util.Map;

import org.yaml.snakeyaml.Yaml;

/**
 * Utilty class that loads a YAML Configuration from file
 * 
 * @author Eric Thill
 *
 */

public class ConfigLoader {
	public static Map<String, Object> load(String filepath) throws FileNotFoundException {
		return load(new FileInputStream(filepath));
	}

	@SuppressWarnings("unchecked")
	public static Map<String, Object> load(InputStream inputStream) {
		Yaml yaml = new Yaml();
		return (Map<String, Object>)yaml.load(inputStream);
	}
	
	@SuppressWarnings("unchecked")
	public static Map<String, Object> load(Reader reader) {
		Yaml yaml = new Yaml();
		return (Map<String, Object>)yaml.load(reader);
	}
}
